﻿using System;
using System.Text;
using System.Drawing;
using System.Buffers;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;

public static partial class NativeAOT
{
    public static Random rnd = new Random();

    public unsafe delegate double delegatefunc_xa_n(double* xa, int n);
    public static delegatefunc_xa_n f_xa_n;

    public unsafe delegate double delegatefunc_xa_nj(double* xa, int n, int j);
    public static delegatefunc_xa_nj f_xa_nj;

    public unsafe delegate double delegatefunc_xa_ya_n(double* xa, double* ya, int n);
    public static delegatefunc_xa_ya_n f_xa_ya_n;

    public unsafe delegate double delegatefunc_xa_ya_mn(double* xa, double* ya, int m, int n);
    public static delegatefunc_xa_ya_mn f_xa_ya_mn;
    public static delegatefunc_xa_ya_mn s_xa_ya_mn;

    public unsafe delegate void delegatefunc_xa(double* x);
    public static delegatefunc_xa f_xa;

    public unsafe delegate double delegatefunc_x(double x);
    public static delegatefunc_x f_x;
    public static delegatefunc_x df_x;

    public unsafe delegate double delegatefunc_xy(double x, double y);
    public static delegatefunc_xy f_xy;

    public unsafe delegate void delegatefunc_x_ya(double x, double* y);
    public static delegatefunc_x_ya s_x_ya;

    public unsafe delegate void delegatefunc_x_ya_n_da(double x, double* y, int n, double* d);
    public static delegatefunc_x_ya_n_da f_x_ya_n_da;
    public static delegatefunc_x_ya_n_da ss_x_ya_n_da;

    public unsafe delegate void delegatefunc_abcd(double a, double* b, double* c, double* d);
    public static delegatefunc_abcd f_abcd;

    public unsafe delegate double delegatefunc_abc(double a, double b, double c);
    public static delegatefunc_abc f_abc;

    public unsafe delegate double delegatefunc_nm_xa_ya_ua_va(int n, int m, double* x, double* y, double* u, double* v);
    public static delegatefunc_nm_xa_ya_ua_va s_nm_xa_ya_ua_va;

    /// <summary>
    /// == 0.0
    /// </summary>
    /// <param name="v"></param>
    /// <returns></returns>
    public static bool EQ0(double v)
    {
        return Math.Abs(v) <= float.Epsilon;
    }

    /// <summary>
    /// != 0.0
    /// </summary>
    /// <param name="v"></param>
    /// <returns></returns>
    public static bool NE0(double v)
    {
        return Math.Abs(v) > float.Epsilon;
    }

    /// <summary>
    /// == 1.0
    /// </summary>
    /// <param name="v"></param>
    /// <returns></returns>
    public static bool EQ1(double v)
    {
        return Math.Abs(v - 1.0) <= float.Epsilon;
    }

    /// <summary>
    /// != 1.0
    /// </summary>
    /// <param name="v"></param>
    /// <returns></returns>
    public static bool NE1(double v)
    {
        return Math.Abs(v - 1.0) > float.Epsilon;
    }
}
